/**************************************************************

Copyright Astrium Services GEO-Information / Spot Image
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

 ***************************************************************/
package com.spotimage.catalog.client.ui;

import com.google.gwt.user.client.Window;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VLayout;
import com.spotimage.catalog.client.shared.Scene;
import com.spotimage.catalog.client.ui.component.MyStaticTextItem;
import com.spotimage.catalog.client.ui.component.MyWindow;
import com.spotimage.catalog.client.util.SceneTypes;
import com.spotimage.catalog.client.util.Util;

/**
 * Show details of a scene in a window.
 */
public class SceneDetailsWindow extends MyWindow {
	
	/**
	 * Build UI.
	 * 
	 * @param scene
	 */
	public SceneDetailsWindow(final Scene scene) {
		super(true, false, true);
		int width = 230;
		setWidth(width);
		final String title = "SPOT" + scene.getId();
		setTitle(title);
		setAutoCenter(false);
		setTop(Ui.HEADER_HEIGHT + 5);
		setLeft(Window.getClientWidth() - width - 10);

		VLayout layout = new VLayout();
		layout.setMargin(5);
		layout.setWidth100();
		layout.setAlign(Alignment.CENTER);
		
		HLayout hLayout = new HLayout();
		hLayout.setWidth100();
		hLayout.setMargin(5);
		hLayout.setAlign(Alignment.CENTER);
		
		DynamicForm dynamicForm = new DynamicForm();
		MyStaticTextItem satellite = new MyStaticTextItem("Satellite", scene.getSatellite()); 
		MyStaticTextItem type = new MyStaticTextItem("Type", SceneTypes.get(scene.getId())); 
		MyStaticTextItem acquisitionDate = new MyStaticTextItem("Acquisition date", scene.getAcquisitionDateString()); 
		MyStaticTextItem cloudCover = new MyStaticTextItem("Cloud cover %", scene.getCloudCoverPercentage()); 
		MyStaticTextItem snowCover = new MyStaticTextItem("Snow cover %", scene.getSnowCoverPercentage()); 
        MyStaticTextItem shift = new MyStaticTextItem("Shift", scene.getShift()); 
        MyStaticTextItem minShift = new MyStaticTextItem("Minimum shift", scene.getMinShift()); 
        MyStaticTextItem maxShift = new MyStaticTextItem("Maximum shift", scene.getMaxShift()); 
        MyStaticTextItem upperLeft = new MyStaticTextItem("Upper left", Util.getFormattedCoordinate(scene.getUpperLeft().getLatitude()) + ", " + 
        																Util.getFormattedCoordinate(scene.getUpperLeft().getLongitude())); 
        MyStaticTextItem upperRight = new MyStaticTextItem("Upper right", Util.getFormattedCoordinate(scene.getUpperRight().getLatitude()) + ", " + 
        																	Util.getFormattedCoordinate(scene.getUpperRight().getLongitude())); 
        MyStaticTextItem lowerLeft = new MyStaticTextItem("Lower left", Util.getFormattedCoordinate(scene.getLowerLeft().getLatitude()) + ", " + 
        																Util.getFormattedCoordinate(scene.getLowerLeft().getLongitude())); 
        MyStaticTextItem lowerRight = new MyStaticTextItem("Lower right", Util.getFormattedCoordinate(scene.getLowerRight().getLatitude()) + ", " + 
        																	Util.getFormattedCoordinate(scene.getLowerRight().getLongitude()));  
        MyStaticTextItem archivingStation = new MyStaticTextItem("Archiving station", scene.getArchivingStation()); 
        
		dynamicForm.setFields(satellite, type, acquisitionDate, cloudCover, snowCover, shift, minShift, maxShift, 
								upperLeft, upperRight, lowerLeft, lowerRight, archivingStation);
		hLayout.addMember(dynamicForm);
		layout.addMember(hLayout);
		
		addItem(layout);
		show();
	}

}
